﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace DemeGo
{
    public partial class FrmMain : Form
    {
        private Game game;

        public FrmMain()
        {
            InitializeComponent();
        }

        private void FrmMain_Load(object sender, EventArgs e)
        {
            //初始化游戏类
            //game = new Game();
            
        }
        private void GameArea_Paint(object sender, PaintEventArgs e)
        {
            if (game != null)//游戏已经初始化了
            {
                game.Draw(e.Graphics, this.GameArea.Size);
            }
        }




        private void GameArea_MouseDown(object sender, MouseEventArgs e)
        {
            if (game != null)
            {
                //调用
                game.MouseDown(e.Location, this.GameArea.Size);
                //重绘
                this.GameArea.Invalidate();
            }
            //游戏结束
            if (game.IsGameOver == true)
            {
                MessageBox.Show("游戏过关！！！");
                game = new Game();

            }
        }


        private void btnStart_Click(object sender, EventArgs e)
        {
            //初始化游戏类
            game = new Game();
            this.GameArea.Invalidate();
        }

        private void btnAboutMe_Click(object sender, EventArgs e)
        {
            FormAboutMe form = new FormAboutMe();
            form.ShowDialog();
        }

        private void GameArea_Load(object sender, EventArgs e)
        {

        }
    }
}

  